package com.zmj.config;

import com.zmj.common.base.ApplicationContextRegister;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @author zmj
 * @date 2021-08-26 16:51
 * <p>
 * Ioc信息输出配置
 */

@Slf4j
@Component
@ConditionalOnProperty(value = "special.ioc-log-enabled", havingValue = "true")
public class IocInfoConfig {

    /**
     * 输出ioc详情
     */
    public IocInfoConfig() {
        ApplicationContext applicationContext = ApplicationContextRegister.getApplicationContext();
        log.info("===========================ioc bean start===========================");
        Arrays.stream(applicationContext.getBeanDefinitionNames()).forEach(it -> log.info(it));
        log.info("===========================ioc bean end============================= 总数为:{}", applicationContext.getBeanDefinitionCount());
    }
}
